/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package management;

import java.io.*;

/**
 *
 * @author Admin
 */
public class WriteFile extends Thread
{
    private IsFile isFile;
    private String path;

    public void setFile(IsFile isFile)
    {
        this.isFile = isFile;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public WriteFile(IsFile isFile, String path)
    {
        this.isFile = isFile;
        this.path = path;
    }

    public WriteFile()
    {
        this(new IsFile(), "");
    }

    @Override
    public void run()
    {
        try
        {
            File file = new File(path);

            if(!isFile.getEndFile())
            {
                DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));

                while(!isFile.getEndFile())
                {
                    dos.writeByte(isFile.getByte());
                }

                dos.close();
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
}